package com.hc.kotlin

fun main() {
    var ka = KClassA()
    println(ka.age)
    var kb = KClassB()
    kb.name = "Rose"
    println(kb.name)
    println(kb.age)
}

//-----类-----
class KClassA{
    var name:String? = null //定义属性 自动生成field的get() set()
    var age = 18 //不可空时必须赋值
}
class KClassB{
    var name = "Jack"
        get() = field.toLowerCase() //覆盖get() set()
        set(value) {
            field = "Hello "+ value
        }
    val age
        get() = (1..18).shuffled().first() //通过计算获取值
}